00001 /* 00002 * Copyright (c) 2013 Battelle Memorial Institute 00003 * Licensed under modified BSD License. A copy of this license can be found 00004 * in the LICENSE file in the top level directory of this distribution. 00005 */ 00006 /* 00007 * base_export.hpp 00008 * 00009 * This is a utility class that is used to implement the rest of the export 00010 * functionality 00011 * 00012 * Created on: April 4, 2019 00013 * Author: Bruce Palmer 00014 */ 00015 00016 #ifndef PSSE33EXPORT_HPP_ 00017 #define PSSE33EXPORT_HPP_ 00018 00019 #include <iostream> 00020 #include <string> 00021 #include <vector> 00022 #include <map> 00023 00024 #include "gridpack/export/data_blocks/export_bus33.hpp" 00025 #include "gridpack/export/data_blocks/export_load33.hpp" 00026 #include "gridpack/export/data_blocks/export_fxshnt33.hpp" 00027 #include "gridpack/export/data_blocks/export_gen33.hpp" 00028 #include "gridpack/export/data_blocks/export_line33.hpp" 00029 #include "gridpack/export/data_blocks/export_xform33.hpp" 00030 #include "gridpack/export/data_blocks/export_area33.hpp" 00031 #include "gridpack/export/data_blocks/export_2term33.hpp" 00032 #include "gridpack/export/data_blocks/export_vscline33.hpp" 00033 #include "gridpack/export/data_blocks/export_icorr33.hpp" 00034 #include "gridpack/export/data_blocks/export_mterm33.hpp" 00035 #include "gridpack/export/data_blocks/export_msect33.hpp" 00036 #include "gridpack/export/data_blocks/export_zone33.hpp" 00037 #include "gridpack/export/data_blocks/export_iarea33.hpp" 00038 #include "gridpack/export/data_blocks/export_owner33.hpp" 00039 #include "gridpack/export/data_blocks/export_facts33.hpp" 00040 #include "gridpack/export/data_blocks/export_swshnt33.hpp" 00041 00042 namespace gridpack { 00043 namespace expnet { 00044 00045 template <class _network> 00046 class PSSE33Export 00047 { 00048 public: 00049 00050 /** 00051 * Constructor 00052 */ 00053 explicit PSSE33Export(boost::shared_ptr<_network> network) : 00054 p_network(network), p_comm(network->communicator()) 00055 { 00056 } 00057 00058 /** 00059 * Destructor 00060 */ 00061 virtual ~PSSE33Export() 00062 { 00063 } 00064 00065 /** 00066 * Write out data in PSS/E v33 format to a file 00067 * @param filename name of file that contains output 00068 */ 00069 void writeFile(std::string filename) { 00070 int me = p_comm.rank(); 00071 std::ofstream fout; 00072 if (me == 0) { 00073 fout.open(filename.c_str()); 00074 } 00075 // Write out individual data blocks 00076 ExportBus33<_network> buses(p_network); 00077 buses.writeBusBlock(fout); 00078 ExportLoad33<_network> loads(p_network); 00079 loads.writeLoadBlock(fout); 00080 ExportFxShnt33<_network> fxshnts(p_network); 00081 fxshnts.writeFxShntBlock(fout); 00082 ExportGen33<_network> generators(p_network); 00083 generators.writeGenBlock(fout); 00084 ExportLine33<_network> lines(p_network); 00085 lines.writeLineBlock(fout); 00086 ExportXform33<_network> xform(p_network); 00087 xform.writeXformBlock(fout); 00088 ExportArea33<_network> area(p_network); 00089 area.writeAreaBlock(fout); 00090 Export2Term33<_network> term2(p_network); 00091 term2.write2TermBlock(fout); 00092 ExportVSCLine33<_network> vscline(p_network); 00093 vscline.writeVSCLineBlock(fout); 00094 ExportImpedCorr33<_network> icorr(p_network); 00095 icorr.writeImpedCorrBlock(fout); 00096 ExportMultiTerm33<_network> mterm(p_network); 00097 mterm.writeMultiTermBlock(fout); 00098 ExportMultiSect33<_network> msect(p_network); 00099 msect.writeMultiSectBlock(fout); 00100 ExportZone33<_network> zone(p_network); 00101 zone.writeZoneBlock(fout); 00102 ExportInterArea33<_network> iarea(p_network); 00103 iarea.writeInterAreaBlock(fout); 00104 ExportOwner33<_network> owner(p_network); 00105 owner.writeOwnerBlock(fout); 00106 ExportFACTS33<_network> facts(p_network); 00107 facts.writeFACTSBlock(fout); 00108 ExportSwShnt33<_network> swshnt(p_network); 00109 swshnt.writeSwShntBlock(fout); 00110 if (me == 0) { 00111 // Write closing 'Q' 00112 fout << "Q" << std::endl; 00113 fout.close(); 00114 } 00115 } 00116 00117 private: 00118 boost::shared_ptr<_network> p_network; 00119 00120 gridpack::parallel::Communicator p_comm; 00121 }; 00122 00123 } /* namespace export */ 00124 } /* namespace gridpack */ 00125 00126 #endif /* PSSE33EXPORT_HPP_ */